package com.woniuxy.service.daily.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.dao.AccidentMapper;
import com.woniuxy.pojo.Accident;
import com.woniuxy.service.daily.AccidentService;

@Service
public class AccidentServiceImpl implements AccidentService{

	@Autowired
	private AccidentMapper accidentMapper;
	@Override
	public PageInfo selectAll(Integer dr_pn,String dr_conditionBy,String dr_condition) {
		// TODO Auto-generated method stub
		PageHelper.startPage(dr_pn, 5);
		List<Accident> list = accidentMapper.selectAll(dr_conditionBy,dr_condition);
		PageInfo pageInfo = new PageInfo(list,3);
		return pageInfo;
	}
	
	public void addAccident(Accident driver) {
		accidentMapper.insertSelective(driver);
		
	}
	@Override
	public void deleteByAccidentId(Integer driverId) {
		accidentMapper.deleteByPrimaryKey(driverId);

	}
	
	public int batchDelete(Integer[] driverIds) {
		return accidentMapper.batchDelete(driverIds);
	}
	
	public Accident selectById(Integer id) {
		return accidentMapper.selectByPrimaryKey(id);
	}
	
	public void updateAccident(Accident accident) {
		accidentMapper.updateByPrimaryKey(accident);		
	}
	
	@Override
	public List<String> selectAllAccidentName() {
		// TODO Auto-generated method stub
		return accidentMapper.selectAllAccidentName();
	}
}
